package algorithm.leetcode.I201to400;

import algorithm.leetcode.ListNode;

public class Q206 {

    public ListNode reverseList(ListNode head) {
        ListNode pre = null;
        ListNode next = null;

        while (head != null) {
            next = head.next; // pre head next
            head.next = pre; // pre<-head
            pre = head; // head(pre)
            head = next; // next(head)
            // next = next.next; //

        }
        return pre;
    }

    public static void main(String[] args) {
        ListNode listNode1 = new ListNode(1);
        ListNode listNode2 = new ListNode(2);
        ListNode listNode3 = new ListNode(3);
        ListNode listNode4 = new ListNode(4);
        listNode1.next = listNode2;
        listNode2.next = listNode3;
        listNode3.next = listNode4;

        Q206 tzs = new Q206();
        System.out.println(tzs.reverseList(listNode1));
        System.out.println(12&7);

    }
}
